import unittest
import sys

def run_all_tests():
    """Run all test files"""
    # Import all test modules
    print("Loading test modules...")
    test_modules = [
        'test_main',
        'test_rag_application',
        'test_optimized_rag',
        'test_app',
        'test_integration'
    ]
    
    # Create test suite
    test_suite = unittest.TestSuite()
    
    # Add tests from each module
    for module_name in test_modules:
        try:
            # Import the module
            module = __import__(module_name)
            
            # Add all tests from the module
            tests = unittest.defaultTestLoader.loadTestsFromModule(module)
            test_suite.addTest(tests)
            print(f"Added tests from {module_name}")
        except ImportError as e:
            print(f"Warning: Could not import {module_name}: {e}")
    
    # Run the tests
    print("\nRunning tests...")
    runner = unittest.TextTestRunner(verbosity=2)
    result = runner.run(test_suite)
    
    # Return appropriate exit code
    return 0 if result.wasSuccessful() else 1

if __name__ == "__main__":
    sys.exit(run_all_tests()) 